package root.board.moviment;

public class Moviment {
	private boolean eatMoviment = false;
	private Position positionFrom = null;
	private Position positionTo = null;
	private boolean castlingMoviment = false;

	public Moviment(Position positionFrom, Position positionTo) {
		this.positionFrom = positionFrom;
		this.positionTo = positionTo;
	}

	@Override
	public boolean equals(Object obj) {
		Moviment nm;
		if (obj instanceof Moviment) {
			nm = (Moviment) obj;
			return nm.getPositionFrom().equals(positionFrom)
					&& nm.getPositionTo().equals(positionTo)
					&& (castlingMoviment == nm.castlingMoviment) && (eatMoviment == nm.eatMoviment);
		} else {
			return false;
		}
	}

	/**
	 * @return the positionFrom
	 */
	public Position getPositionFrom() {
		return positionFrom;
	}

	/**
	 * @return the positionTo
	 */
	public Position getPositionTo() {
		return positionTo;
	}

	/**
	 * @return the castlingMoviment
	 */
	public boolean isCastlingMoviment() {
		return castlingMoviment;
	}

	/**
	 * @return the eatMoviment
	 */
	public boolean isEatMoviment() {
		return eatMoviment;
	}

	/**
	 * @param castlingMoviment
	 *            the castlingMoviment to set
	 */
	public void setCastlingMoviment(boolean castlingMoviment) {
		this.castlingMoviment = castlingMoviment;
	}

	public void setEatMoviment() {
		eatMoviment = true;
	}

	/**
	 * @param positionFrom
	 *            the positionFrom to set
	 */
	public void setPositionFrom(Position positionFrom) {
		this.positionFrom = positionFrom;
	}

	/**
	 * @param positionTo
	 *            the positionTo to set
	 */
	public void setPositionTo(Position positionTo) {
		this.positionTo = positionTo;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "Movement from position " + positionFrom.getX() + ":" + positionFrom.getY()
				+ " to position " + positionTo.getX() + ":" + positionTo.getY() + ".";

	}
}
